#pragma once

#include <algorithm/analytical_model/algorithm/cuda/inter_op/Data.h>

namespace solar::cuda
{
    class SimplifiedMethod
    {
        public:
            // 成像平面
            SimplifiedMethod(float3* helio_vertices, float3* recv_vertices, float3 helio_normal,
                             float3 recv_normal, float3 helio_pos, float3 target_center,
                             float3 helio_size, int2 row_col, float DNI, cudaStream_t stream = nullptr);
            // 圆柱形接收器
            SimplifiedMethod(float3* helio_vertices, float3 recv_size, float3 helio_normal,
                             float3 recv_pos, float3 helio_pos, float3 target_center,
                             float3 helio_size, int2 row_col, float DNI, float* d_array = nullptr,
                             cudaStream_t stream = nullptr);
            // NEG
            /**
             * 圆柱型接收器下的定日镜镜场仿真
             * @param d_image_plane_x_z_axes float3数组
             * 存放所有定日镜的成像平面的X/Z轴，世界坐标系下
             * @param d_center_bias float4数组
             * 存放偏移后的重心(x,y,z)[世界坐标系下，定日镜平面上]，以及阴影遮挡系数w
             * @param d_flux_params float3数组 存放峰值peak,sigma1,sigma2
             * @param recv_size 圆柱型接收器的尺寸
             * @param recv_pos  接收器中心的位置
             * @param row_col   接收器表面被划分的尺寸数目
             */
            SimplifiedMethod(float3* d_image_plane_x_z_axes, float4* d_center_bias,
                             float3* d_flux_params, int n, float3 recv_size, float3 recv_pos,
                             int2 row_col, cudaStream_t stream = nullptr);
            ~SimplifiedMethod();

            /// @brief 绘制平面接收器上的通量图
            void drawFluxMap();
            /// @brief 绘制圆柱形接收器上的通量图
            void drawFluxMapCylinder();

            void setHelioVertices(float3* helio_vertices);
            void setRecvVertices(float3* recv_vertices);
            auto loadNormalDistributionArray() -> bool;
            void setCudaStream(const cudaStream_t& stream);

            // 镜场中得到的信息
            float3 helio_size_{};
            float3 helio_normal_{};
            float3 helio_vertices_[4]{};
            float3 recv_vertices_[4]{};
            float3 focus_center_{};
            float3 helio_pos_{};
            float3 plane_normal_{};
            float helio_reflectivity_ = 0.88F;
            float DNI_{};
            int2 row_col_{};
            float shadow_block_factor_ = 0.0F;
            float3 center_bias_{0, 0, 0};
            // 解析模型参数
            float sigma1_ = 0.0;
            float sigma2_ = 0.0;
            float correlation_ = 0.0;
            float peak_ = 0.0;
            // 计算结果
            float* d_array_{};
            bool external_d_array_ = false;
            // 圆柱形接收器
            float3 recv_pos_{};
            float3 recv_size_{};
            float* d_normal_distribution{nullptr};
            cudaStream_t stream_ = nullptr;
            bool external_stream_ = false;
    };
} // namespace solar::cuda
